package com.br4mmie.asciistory.mission;

import java.io.BufferedReader;
import java.io.IOException;

import com.br4mmie.asciistory.CharImage;

/**
 * @author Ken Veensta
 *
 */
public class Weapon extends Item
{
	private int damage;
	
	public Weapon( String name, String description, int damage, CharImage itemImage, int gold, String type )
	{
		super( name, description, itemImage, gold, type);
		this.damage = damage;
	}
	
	public static Weapon fromFile(String line, BufferedReader file) throws IOException
	{
		String name = line.substring(2);
		int d = 0;			//damage
		CharImage i = null;	//image on the map
		String z = null;	//description
		int g = 0;			//gold
		String t = null;	//type
		while (true)
		{
			line = file.readLine();
			if (line == null) break;
			
			if(line.startsWith("d "))
			{
				d = Integer.parseInt(line.substring(2));
			}
			else if(line.startsWith("i "))
			{
				i = new CharImage(1, 1);
				i.setImage(line.substring(2));
			}
			else if(line.startsWith("z "))
			{
				z = line.substring(2);
			}
			else if(line.startsWith("g "))
			{
				g = Integer.parseInt(line.substring(2));
			}
			else if(line.startsWith("t "));
			{
				t = line.substring(2);
			}
		}
		return new Weapon(name, z, d, i, g, t);
	}
	
	public int getDamage()
	{
		return damage;
	}


}
